using Microsoft.Xna.Framework;
using Rocuna.Graphics.Constants;
using Rocuna.Graphics.Core;

namespace WindowsGameLibrary1.Cameras
{
    /// <summary>
    /// Target camera.
    /// </summary>
    public class TargetCamera : Camera
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="TargetCamera"/> class.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="target">The target.</param>
        /// <param name="game">The game.</param>
        public TargetCamera(Vector3 position, Vector3 target, Game game)
            : base(game)
        {
            Position = position;
            Target = target;
        }

        #region Properties

        public override string Name
        {
            get
            {
                return
                    CamerasNames.TargetCamera;
            }
        }

        #endregion

        #region Methods

        public override void Update(GameTime gameTime)
        {
            var forward = Target - Position;
            var side = Vector3.Cross(forward, Vector3.Up);
            var up = Vector3.Cross(forward, side);
            View = Matrix.CreateLookAt(Position, Target, up);
        }

        #endregion
    }
}